home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / TransSkel / Convenience / Dialog Item Stuff / SkelDlogBtnOutliner.c next >
Encoding:
C/C++ Source or Header  |  1994-02-20  |  1.6 KB  |  54 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Associate a button-outlining function with the given item, which should
  3.  * be a user item.  The item outlined will be the default item, and should
  4.  * be a push button.  The user item bounding rectangle is positioned and
  5.  * sized to surround the default item.
  6.  *
  7.  * There's a subtle point here -- the outline drawing proc is called when the
  8.  * user item rect is becomes invalid, but the drawing proc bases its calculations
  9.  * on the rect for the default button item.  This works because the rect it
  10.  * calculates based on the button rect is identical to that of the user item.
  11.  *
  12.  * If you change the button's hiliting state, you should make sure the outline
  13.  * is redrawn by invalidating its bounding rectangle.  You can avoid unnecessary
  14.  * redrawing by using SkelSetDlogCtlHilite() like so:
  15.  *
  16.  *    if (SkelSetDlogCtlHilite (dlog, buttonItem, newHilite)
  17.  *    {
  18.  *        SkelGetDlogRect (dlog, outlineItem, &r);
  19.  *        InvalRect (&r);
  20.  *    }
  21.  */
  22.  
  23. # include    "TransSkel.h"
  24.  
  25.  
  26. /*
  27.  * Draw heavy outline around default dialog button.
  28.  */
  29.  
  30. static pascal void
  31. DrawDlogButtonOutline (DialogPtr d, short item)
  32. {
  33.     SkelDrawButtonOutline (SkelGetDlogCtl (d, ((DialogPeek) d)->aDefItem));
  34. }
  35.  
  36.  
  37. pascal void
  38. SkelSetDlogButtonOutliner (DialogPtr d, short item)
  39. {
  40. short    type;
  41. Handle    h;
  42. Rect    r, rJunk;
  43. short    defItem;
  44.  
  45.     /* find default item bounding rectangle */
  46.     defItem = ((DialogPeek) d)->aDefItem;
  47.     GetDItem (d, defItem, &type, &h, &r);
  48.  
  49.     /* get user item, position rectangle, and install draw proc using it */
  50.     GetDItem (d, item, &type, &h, &rJunk);
  51.     InsetRect (&r, -4, -4);
  52.     SetDItem (d, item, type, (Handle) DrawDlogButtonOutline, &r);
  53. }
  54.